package com.mindether.llyblog.pojo;

import java.io.Serializable;

public class ApiResponse implements Serializable {
    private boolean flag;
    private Integer code;
    private String message;
    private Object data;

    public static ApiResponse ok(){
        ApiResponse apiResponse=new ApiResponse();
        apiResponse.setFlag(true);
        apiResponse.setCode(StatusCode.OK);
        return apiResponse;
    }

    public static ApiResponse error(){
        ApiResponse apiResponse=new ApiResponse();
        apiResponse.setFlag(false);
        apiResponse.setCode(StatusCode.ERROR);
        return apiResponse;
    }

   public  static interface  StatusCode{
        static  final  Integer OK=20000;
        static  final  Integer ERROR=20004;
    }

    public boolean isFlag() {
        return flag;
    }

    public ApiResponse setFlag(boolean flag) {
        this.flag = flag;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public ApiResponse setCode(Integer code) {
        this.code = code;
        return this;
    }
    public String getMessage() {
        return message;
    }
    public ApiResponse setMessage(String message) {
        this.message = message;
        return this;
    }
    public Object getData() {
        return data;
    }
    public ApiResponse setData(Object data) {
        this.data = data;
        return this;
    }
    public ApiResponse() {
    }
    public ApiResponse(boolean flag, Integer code, String message, Object data) {
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
